package com.teach.gui.until;

import com.teach.gui.Constaint.Constant;
import com.teach.gui.GUITest;

import java.awt.*;

/**
 * CLASS:GUITest03：
 * TODU:
 * date:2021/1/25、20:08
 * version:0.1
 */
public class GUITest03 extends MyFrame{
    public Image bg = ImageUutil.getImage("img/bg.jpg");
    public Image erath = ImageUutil.getImage("img/earth.jpg");
    public int x;
    public int y=50;
    public boolean right;

    public GUITest03(){
        super.init("03");
        this.x = x;
        this.y = y;
        this.speed=40;
    }
    public int speed;
    public int w;
    public  int h;
    @Override
    public void paint(Graphics g) {
        g.drawImage(bg,0,0,null);
        g.drawImage(erath,x,y,null);
        if(right){
            x+=speed;
        }else {
            x-=speed;
        }
        //x+=speed;
        //y+=speed;
        this.w=erath.getWidth(null);
        this.h=erath.getHeight(null);
        if(this.x>= Constant.WINDOE_WIDTH-this.w){
            right=false;
        }
        if(x<0){
            right=true;
        }
    }

    public static void main(String[] args) {
        new GUITest03();
    }
}
